package com.delete.controller;

import com.delete.service.DeleteService;
import com.feign.common.R;
import com.feign.domain.bo.FileBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/delete")
public class DeleteController {

    @Autowired
    private DeleteService deleteService;

    /**
     * 批量删除文件
     * @param fileBo 文件路径 英文,分割
     * @return
     */
    @DeleteMapping("/filePaths")
    public R deleteFilePaths(@RequestBody FileBo fileBo) {
        List<String> list = Arrays.stream(fileBo.getFilePath().split(",")).toList();
        deleteService.deleteFilePaths(list);
        return R.ok("删除成功");
    }

}
